import { THEME_LIGHT } from '@/constants'
import { parse, stringify } from 'zipson'
import { defineStore } from 'pinia'

export const useThemeStore = defineStore('themeStore', {
  state: () => ({
    // 主题模式
    themeType: THEME_LIGHT
  }),
  getters: {
    /**
   * 当前主题
   */
  themeType: (state) => state.themeType,
  },
  actions: {
     /**
     *  切换主题模式
     */
    changeThemeType( newTheme:string) {
      this.themeType = newTheme
    }
  },
  persist: {
    key: 'themeStore',
    storage: localStorage,
    serializer: {
      deserialize: parse,
      serialize: stringify,
    },
  },
})


